<template>
   <div id="login" class="flex_center">
    <span><h5>
        <img src="../../src/assets/icon.png" />企业管理与综合服务平台V1.0 - 政府端
      </h5></span>
    <div class="loginBox">
      <div class="loginBox1">
        <h3 class="flex_center w_100 mb30">企业用户登录</h3>
        <el-form 
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width=""
          class="demo-ruleForm"
        >
          <el-form-item label="" prop="user">
            <span>用户名：</span>
            <br>
            <el-input v-model="ruleForm.user"  placeholder="手机号码\邮箱\用户名" style="width: 500px"></el-input>
          </el-form-item>
          <el-form-item label="" prop="passWord">
            <span>密码:</span>
            <br>
            <el-input
              v-model="ruleForm.passWord"
              placeholder="6-16字母或数字，区分大小写"
              show-password
            ></el-input>
          </el-form-item>
          
          <div class="flex_center">
            <el-button type="primary" @click="submitForm('ruleForm')"
              >立即登录</el-button
            >
          </div>
        </el-form>
        
      </div>
    </div>
  </div>
</template>

<script>
import { useRouter } from 'vue-router'
export default {
  name: "login",
  data() {
    return {
      ruleForm: {
        user: "",
        passWord: "",
      },
      rules: {
        user: [
          { required: true, message: "请输入用户名", trigger: "blur" },
          { min: 1,  message: "请输入用户名", trigger: "blur" },
        ],
        passWord: [
          { required: true, message: "请输入密码", trigger: "blur" },
          { min: 6, max: 16, message: "长度在 6 到 16 个字符", trigger: "blur" },
        ],
      },
    };
  },
  setup()
  {

const router = useRouter();
return{
router
}
  }
  
  ,
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$message({
            message: "恭喜你，登录成功",
            type: "success",
          });
          this.$router.push({ path: "/ContainerView" });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    register() {
      router.push({ path: "/register" });
    },
  },
};
</script>

<style lang="less" scoped>
#login {
  width: 100%;
  height: 800px;

  // height: 100%;
  background-image: url(../assets/login.jpg);
  background-size: cover;
  display: flex;
  justify-content: center;
  align-items: center;//////////
  // background-image: linear-gradient(
  //   to bottom right,
  //   rgb(102, 177, 255),
  //   rgb(217, 236, 255)
  // );
  .loginBox {
    width: 30%;
    padding: 50px;
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.8);
    // box-shadow: 0px 0px 10px rgb(217, 236, 255);
    border-radius: 15px;
  }

  .loginBox1 {
    width: 40%;
  }
  h5{
    position: absolute;
    top: 2px;
    left: 10px;
  }
}
</style>
